package com.power.sifa.statistics.controller;

import com.plf.common.domain.ResponseDTO;
import com.power.sifa.statistics.api.ICorrectionWarningFeign;
import com.power.sifa.statistics.service.CorrectionWarningService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@RestController
@RequiredArgsConstructor
@Api(value = "CorrectionWarningController", tags = {"社区矫正告警处理"})
public class CorrectionWarningController implements ICorrectionWarningFeign {

    @Resource
    private CorrectionWarningService correctionWarningService;

    @Override
    public void generateWord(List<String> warnIds, HttpServletResponse response) {
        Assert.notNull(warnIds, "预警id不能为空");

        ExecutorService exe = Executors.newFixedThreadPool(10);

        if (warnIds.size() == 1) {
            correctionWarningService.generateWord(warnIds.get(0), response);
        } else {
            correctionWarningService.generateWords(warnIds, response);
        }
    }
}
